# coding: utf-8
from django.db import models
from jd_oss.tools import get_choices


class AssetInfo(models.Model):

    class Meta:
        db_table = u"it"
        ordering = ["it_id"]
        verbose_name = u'IT资产管理'

    ASSET_STATUS = (
        (1, u"使用中"),
        (2, u"未使用"),
        (3, u"未找到"),
        (4, u"已损坏"),
        (5, u"被借用"),
    )

    ASSET_TYPE = get_choices(Meta().db_table, 'it_type')

    ASSET_DEP = get_choices(Meta().db_table, 'it_dep')

    ASSET_USER = get_choices(Meta().db_table, 'it_user')

    it_id = models.AutoField(primary_key=True, verbose_name=u"编号")
    it_serial = models.CharField(
        max_length=128, verbose_name=u"资产序列号", default="示例格式:SHBRLE0030")
    it_type = models.CharField(
        max_length=32, choices=ASSET_TYPE, verbose_name=u"资产类型", blank=True)
    # it_type = models.CharField(max_length=32,verbose_name=u"资产类型")
    it_size = models.CharField(
        max_length=128, verbose_name=u"尺寸/型号", blank=True)
    it_brand = models.CharField(max_length=32, verbose_name=u"品牌", blank=True)
    it_os = models.CharField(max_length=128, verbose_name=u"系统", blank=True)
    it_cpu = models.CharField(max_length=32, verbose_name=u"CPU", blank=True)
    it_mem = models.CharField(max_length=32, verbose_name=u"内存", blank=True)
    it_ip = models.CharField(max_length=32, verbose_name=u"IP", blank=True)
    it_mac = models.CharField(
        max_length=128, verbose_name=u"MAC地址", blank=True)
    it_dep = models.CharField(
        max_length=32, choices=ASSET_DEP, verbose_name=u"部门", blank=True)
    # it_user = models.CharField(max_length=32,verbose_name=u"使用者")
    it_user = models.CharField(
        max_length=32, choices=ASSET_USER, verbose_name=u"使用者", blank=True)
    it_status = models.CharField(
        max_length=32, choices=ASSET_STATUS, verbose_name=u"状态", blank=True)
    it_reason = models.CharField(
        max_length=32, verbose_name=u"使用原因", blank=True)
    it_usetime = models.DateField(
        auto_now_add=True, verbose_name=u"使用时间", blank=True)
    it_buytime = models.DateField(
        auto_now_add=True, verbose_name=u"购买时间", blank=True)
    it_cost = models.CharField(max_length=32, verbose_name=u"价格", blank=True)
    it_channel = models.CharField(
        max_length=32, verbose_name=u"购买渠道", blank=True)
    it_detail = models.CharField(
        max_length=1000, verbose_name=u"详细信息", blank=True)
    it_dec = models.CharField(max_length=1000, verbose_name=u"备注", blank=True)
    it_respon = models.CharField(
        max_length=32, verbose_name=u"责任人", blank=True, default=u"无")

    def __unicode__(self):
        return self.it_serial + ' ' + self.it_type
